﻿@{
    ViewBag.Title = "RoomDetail"; 
    Layout = "~/Views/Shared/_Form.cshtml";
} 
<script>
    var keyValue = request('keyValue');
    var BillId = request('BillId'); 
    $(function () {
        
        //房间
        $("#PStructId").ComboBox({
            url: "../../ResourceManage/RS_PStructUser/GetRoomlist",
            param: { keyValue: BillId },
            height: "200px",
            id: "id",
            text: "text",
            description: "==请选择所属房间==",
        });
        //部位
        $("#PSMemoValue").ComboBox({
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson",
            param: { EnCode: "ProductDirt" },
            height: "200px",
            id: "id",
            text: "text",
            description: "==请选择==",
        });

        //物品名称
        $("#NameValue").ComboBox({ 
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson",
            param: { EnCode: "ProductName" },
            height: "200px",
            id: "id",
            text: "text",
            description: "==请选择==",
        });
        
        if (!!keyValue) {
            var rowdata = top.Form.$("#gridTable_RoomDetail").jqGridRow()[0];
            $("#form1").SetWebControls(rowdata);

        }
    });

    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var $gridTable = top.Form.$("#gridTable_RoomDetail");
        var postData = $("#form1").GetWebControls("");
        postData["PSMemo"] = $("#PSMemoValue").attr("data-text");
        postData["Name"] = $("#NameValue").attr("data-text");
        postData["RoomId"] = $("#PStructId").attr("data-value");
        postData["RoomName"] = $("#PStructId").attr("data-text");
        if (!!keyValue) {
            $gridTable.setRowData(keyValue, postData);
        } else {
            $gridTable.addRowData(($gridTable.jqGrid("getRowData").length + 1), postData);
        }
        dialogMsg("操作成功。", 1);
        dialogClose();
    }

</script>

<div id="RoomDetailAdd">
    <table class="form" style="width:90%;">
        <tr>
            <th class="formTitle">所属房间<font face="宋体">*</font></th>
            <td class="formValue"><div id="PStructId" type="select" class="ui-select" /></td>
        </tr> 
        <tr>
            <th class="formTitle">物品名称<font face="宋体">*</font></th>
            <td class="formValue"><div id="NameValue" type="select" class="ui-select" /></td>
        </tr>
        <tr>
            <th class="formTitle">物品编号</th>
            <td class="formValue"><input id="Code" type="text" class="form-control" /></td>
        </tr>
        <tr>
            <th class="formTitle">类别</th>
            <td class="formValue"><input id="ModelNo" type="text" class="form-control" /></td>
        </tr>
        <tr>
            <th class="formTitle">数量</th>
            <td class="formValue">
                <input id="Num" type="number" class="form-control" value="1" />
            </td>
        </tr> 
        <tr>
            <th class="formTitle">备注</th>
            <td class="formValue">
                <textarea id="PSMemo" class="form-control" style="height: 50px;"></textarea>
            </td>
        </tr>
    </table>
</div>